<%--
  Created by IntelliJ IDEA.
  User: Administrator
  Date: 2016/3/6 0006
  Time: 下午 3:35
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@taglib prefix="s" uri="http://www.springframework.org/tags" %>
<html>
<head>
    <title>网上书店</title>
    <%--<link rel="stylesheet" type="text/css" href="../../resources/css/bootstrap.css">--%>
    <%--<script type="text/javascript" src="../../resources/js/jquery-2.2.1.js"></script>--%>
    <%--<script type="text/javascript" src="../../resources/js/bootstrap.js"></script>--%>
    <script src="//cdn.bootcss.com/jquery/1.11.3/jquery.min.js"></script>
    <script type="text/javascript" src="../../resources/js/angular.js"></script>
    <link rel="stylesheet" type="text/css" href="../../resources/css/common.css">
    <link rel="stylesheet" type="text/css" href="../../resources/css/main.css">

    <script type="text/javascript">
        $().ready(function () {
            var $menuItem = $("#menu a");
            var $nav = $("#nav a");
//            var $menu = $("#menu dl");

            //书籍的子分类在父分类查询出来之后再通过ajax查询
            $nav.click(function () {
                var iframe = $("#iframe");
                var nav = $(this).attr("name");
                $.ajax({
                    url: "/book/subCategory.html",
                    type: "post",
                    data: "subCategory=" + nav,
                    dataType: "json",
                    success: function (data) {
                        $("#subCategory").empty();
                        for (i = 0; i < data.length; i++) {
                            console.info("subCategory = " + data);
                            var subCategoryName = data[i];
                            //eval("(" + data[i] + ")");
                            console.info("subcat=" + subCategoryName);
                            $("#subCategory").append(
                                    "<dd>" +
                                    "<a href='/book/list.html?subCategoryName=" + subCategoryName.subCategoryName + "' target='iframe'>" + subCategoryName.subCategoryName + "</a>" +
                                    " </dd>"
                            );
                        }
                        var subCategory = $("#subCategory a:first").attr("href");
                        iframe.attr("src", subCategory);
                    }
                });
            });


//
//            $nav.click(function () {
//                var $this = $(this);
//                $nav.removeClass("current");
//                $this.addClass("current");
//                var $currentMenu = $($this.attr("href"));
//                $menu.hide();
//                $currentMenu.show();
//                $("#iframe").attr("src", $($this.attr("href") + " dd a:first").attr("href"));
//                return false;
//            });
////
//            $menuItem.click(function () {
//                var $this = $(this);
//                $menuItem.removeClass("current");
//                $this.addClass("current");
//            });

        });
    </script>
</head>
<body>
<table class="main">
    <tr>
        <th class="logo">
            <a href="#">
                网上书店购物平台
            </a>
        </th>
        <th>
            <div id="nav" class="nav">
                <ul>
                    <c:forEach items="${category}" var="c" varStatus="s">
                        <li>
                            <a name="${c.category_name}"> ${c.category_name}</a>
                        </li>
                    </c:forEach>

                    <%--<li>--%>
                    <%--<a href="#partner">计算机</a>--%>
                    <%--</li>--%>
                    <%--<li>--%>
                    <%--<a href="#settle">医学</a>--%>
                    <%--</li>--%>
                    <%--<li>--%>
                    <%--<a href="#student">历史</a>--%>
                    <%--</li>--%>
                    <%--<li>--%>
                    <%--<a href="#holiday">农林</a>--%>
                    <%--</li>--%>
                </ul>
            </div>
            <div class="link">
                <span>您好!${loginUser} </span>
                <a href="logout.html" target="_top">[退出]</a>
            </div>

        </th>
    </tr>
    <tr>
        <td id="menu" class="menu">
            <dl id="subCategory" class="default">
                <c:forEach items="${subCategory}" var="c" varStatus="s">
                    <dd>
                        <a href="/book/list.html" target="iframe" name="${c.subCategoryName}"> ${c.subCategoryName}</a>
                    </dd>
                </c:forEach>

                <%--<dd>--%>
                <%--<a href="/book/list.html" target="iframe">Java</a>--%>
                <%--</dd>--%>
                <%--<dd>--%>
                <%--<a href="${base}/maintain/teachertMaintain.html" target="iframe">C++</a>--%>
                <%--</dd>--%>
                <%--<dd>--%>
                <%--<a href="${base}/maintain/courseMaintain.html" target="iframe">C#</a>--%>
                <%--</dd>--%>
                <%--<dd>--%>
                <%--<a href="${base}/maintain/majorMaintain.html" target="iframe">.NET</a>--%>
                <%--</dd>--%>
            </dl>


            <%--<dl id="student">--%>
            <%--<dt>学生管理</dt>--%>
            <%--<dd>--%>
            <%--<a href="${base}/student/selectCourse.html" class="current" target="iframe">选课</a>--%>
            <%--</dd>--%>
            <%--<dd>--%>
            <%--<a href="${base}/student/courseTable.html" class="current" target="iframe">选课信息</a>--%>
            <%--</dd>--%>
            <%--<dd>--%>
            <%--<a href="${base}/student/viewGrade.html" class="current" target="iframe">查看成绩</a>--%>
            <%--</dd>--%>
            <%--</dl>--%>
            <%--<dl id="settle">--%>
            <%--<dt>结算</dt>--%>
            <%--<dd>--%>
            <%--<a href="${base}/settlement/list.html" class="current" target="iframe">结算</a>--%>
            <%--</dd>--%>
            <%--</dl>--%>
        <td>
            <iframe id="iframe" name="iframe" src="/book/list.html?subCategoryName=-1"
                    frameborder="0"></iframe>
        </td>
    </tr>
</table>
</body>
</html>
